﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class admin_admin_videoimg_edit : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                bd();
            }
        }

        protected void bd()
        {
            int v_id = int.Parse(Request["v_id"]);
            txtv_id.Text = v_id.ToString();
            var classid = Request["classid"];
            hidclassid.Value = classid;
            var id = Request["id"];
            txtId.Text = id;
            //Web_video_imgBLL bll = new Web_video_imgBLL();
            //Web_video_img img = bll.GetElementById(id);
            //lblPic.Text = img.V_img;

        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            //上传路径
            string path = Server.MapPath("~/videouploadImg/");
            int v_id = int.Parse(Request["v_id"]);
            int classid = int.Parse(Request["classid"]);
            //判断是否上传文件
            if (flImg.HasFile)
            {
                //        try
                //        {
                //            //取得文件的扩展名,并转换成小写
                //            string fileExtension = System.IO.Path.GetExtension(this.flImg.FileName).ToLower();

                //            string fileName = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + "_" + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString()  + fileExtension;
                //            this.flImg.PostedFile.SaveAs(path + fileName);

                //            Web_video_img img = new Web_video_img();
                //            img.V_id = v_id;
                //            img.Id = txtId.Text;
                //            img.V_img = fileName;
                //            img.V_classid = classid;
                //            Web_video_imgBLL bll = new Web_video_imgBLL();
                //            if (bll.Update(img) > 0)
                //            {
                //                ClientScript.RegisterStartupScript(GetType(), "a", "alert('修改成功');document.location='admin_video_img.aspx';", true);
                //            }
                //            else
                //            {
                //                ClientScript.RegisterStartupScript(GetType(), "a", "alert('修改失败，请重试');", true);
                //            }
                //        }
                //        catch (Exception ex)
                //        {
                //            ClientScript.RegisterStartupScript(GetType(), "a", "alert('修改失败，请重试');", true);
                //        }
                //    }
                //    else
                //    {
                //        if (lblPic.Text == "")
                //        {
                //            ClientScript.RegisterStartupScript(GetType(), "a", "alert('请选择上传的图片');", true);
                //        }
                //        else
                //        {
                //            Web_video_img img = new Web_video_img();
                //            img.V_id = v_id;
                //            img.Id = txtId.Text;
                //            img.V_img = flImg.FileName;
                //            img.V_classid = classid;
                //            Web_video_imgBLL bll = new Web_video_imgBLL();
                //            if (bll.Update(img) > 0)
                //            {
                //                ClientScript.RegisterStartupScript(GetType(), "a", "alert('修改成功');document.location='admin_video_img.aspx';", true);
                //            }
                //            else
                //            {
                //                ClientScript.RegisterStartupScript(GetType(), "a", "alert('修改失败，请重试');", true);
                //            }
                //        }
                //}
            }
    }
}
